{% extends 'blogobj/layout.html' %}
{% block styles %}
    {#    <script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>#}
    {#    <script src="//cdn.bootcss.com/jquery-validate/1.15.1/jquery.validate.js"></script>#}
    {#    <script src="//cdn.bootcss.com/jquery-validate/1.15.1/additional-methods.js"></script>#}
    <style>
        body {
            font-family: "微软雅黑", "宋体", "Times New Roman", serif;
        }
    </style>
{% endblock %}
{% block blog_header %}


    <section class="all_page_slider_bg">
        <div class="container">
            <div class="row">
                <div class="col-xs-12">
                    <div class="normal_service_text all_page_slider_text">
                        <h2>博客详情</h2>
                        <ol class="breadcrumb">
                            <li><a href="{{ url_for('.blog_index') }}">首页</a><span></span></li>
                            <li class="active"><a href="#">博客</a></li>
                        </ol>
                    </div>
                </div><!-- column End -->
            </div><!-- row End -->
        </div><!-- container End -->
    </section>
{% endblock %}

{% block main_content %}
    <div class="container">
        <div class="panel panel-info col-md-offset-1 col-md-8">
            <div class="row">
                <article class="single_post "
                         style="align-content: center; color: #222222; border: solid #fcfcfc; background-color: #fcfcfc;">


                    <div class="pull-right">
                        <span class="label label-success">阅读量：<span>{{ art.numbrowse }}</span></span>
                        <span class="label label-info">评论：<span>{{ numcomment }}</span></span>
                    </div>
                    <div class=" title" style="color: #0c0c0c">
                        <h2>{{ art.title }}</h2>
                    </div>
                    <div class="pull-right">
                        <span class="label label-primary" style="background-color: #7cd8a9">作者:
                            {{ art.author }}
                        </span>
                        <span class="label label-info">{{ art.releasetime.strftime('%Y-%m-%d %H:%M:%S') }}</span>
                    </div>
                    <div class="image">
                        <img src="{{ url_for('.send_file', filename=art.faceimage if art.faceimage else '') if art.faceimage else '/blogobj/img/default.jpg' }}"
                             alt="博客图片" width="300px" height="200px">
                    </div>
                    <div>
                        <p class="text-primary "><strong>{{ art.preface }}</strong></p>
                        <div class="" id="log">
                        </div>
                    </div>
                    <div class="blog_datail_text">
                        <span class="label label-success"><i class="fa fa-pencil-square"> 评论~_~</i></span>
                    </div>

                    <div>
                            <form action="" method="post">
                                {{ form.csrf_token }}
                                {{ form.body(cols="35", rows="3" ) }}
                                {% if form.body.errors %}
                                    {% for error in form.body.errors %}
                                        <div class="alert alert-success ">
                                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                                            {{ error }}
                                        </div>
                                    {% endfor %}

                                {% endif %}
                                <input type="hidden" name="page_id" value="{{ art.id }}">
                                {{ form.name(type="hidden") }}
                                <div>
                                    <button type="submit" class="btn btn-success">提交</button>
                                    <button type="reset" id="resetcomment" class="btn btn-warning">重置</button>
                                </div>
                            </form>
                       </div>
                    <tr>
                        <td>
                            <div class="  pull-right">
                                <div>
                                    <!-- JiaThis Button BEGIN -->
                                    <div class="jiathis_style">
                                        <a href="#share" id="share" style="font-size:10px;">~_~分享</a>
                                    </div>

                                </div>
                            </div>
                        </td>
                    </tr>

                </article>
            </div>

            {% for this_comment in this_comments %}
                <div class="panel panel-info">
                    <div class="panel-timeline">
                        <span class="label label-success"><i class="fa fa-user"> 用户： </i>{{ this_comment.name }}</span>
                    </div>
                    <div class="panel-body">
                        <ul>
                            <li>
                                <div class=" pull-left" style="background-color: #efefef; line-height: 28px;">
                            <span class="label label-default">
                                内容：</span>{{ this_comment.body }}
                                </div>
                                <div class="pull-right text-xs">
                                    <span class="label label-info">时间:</span> {{ this_comment.releasetime.strftime('%Y-%m-%d %H:%M:%S') }}
                                    <br><span class="label label-info">IP:</span> {{ this_comment.ip }}
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            {% endfor %}

            <div class="post_share fix">
                <div class="pegination">
                    <ul>
                        <li><a href="{{ url_for('.blog_index') }}">返回</a></li>
                        <li><a href="#">回顶部</a></li>
                    </ul>
                </div>

            </div>
            <!-- single blog detail End -->

        </div>
    </div>
{% endblock %}

{% block scripts %}

    <script>

        var $log = $("#log"), str = "{{ art.body }}",
                newstr = str.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&nbsp;/g, " ").replace(/&#34;/g, " ");
        html = $.parseHTML(newstr);
        $log.append(html);
        {#    document.getElementById("log").innerHTML = "{{ art.body }}"#}

    </script>
    <script>
        if (!document.cookie.isNew == true) {
            $.ajax({
                url: '{{ url_for('blog.num_browse',id=art.id) }}',
                method: 'POST',
                data: {isnew: 1},
                success: function (res) {
                    console.log('ok')
                }
            });
        }
    </script>
    <script>
        $(document).ready(function () {
            var input = document.getElementsByTagName("table");
            for (var i = 0; i <= input.length; i++) {
                input[i].setAttribute("class", "table  table-hover table-bordered");
            }
        });
    </script>

{% endblock %}